<template>
  <div class="container">
    <template v-if="!loading && list.length">
      <div class="title-box"><div class="title">乡镇好差评排行</div></div>
      <div class="data-box">
        <div v-for="(item, index) in list" :key="index">
          <div class="data-title">
            <div class="title-number" :style="index < 3 ? 'background-color: #0c92ff; ' : 'background-color: #80807f;'" >
              {{index + 1}}
            </div>
            <div style="font-weight: 550;">{{item.name}}</div>
          </div>
          <div class="data-content">
            <div style="font-size: 12px; width: 25%;">
              <span style="color: #a9a4a4;">办件数：</span>
              <span style="font-size: 13px; color: #060606;">{{item.itemCount}}</span>
            </div>
            <div style="font-size: 12px;  width: 25%;">
              <span style="color: #a9a4a4;">评价数：</span>
              <span style="font-size: 13px; color: #060606;">{{item.appraiseCount}}</span>
            </div>
            <div style="font-size: 12px;  width: 20%;">
              <span style="color: #a9a4a4;">差评数：</span>
              <span style="font-size: 13px; color: #060606;">{{item.badAppraiseCount}}</span>
            </div>
            <div style="font-size: 12px;  width: 30%;">
              <span style="color: #a9a4a4;">满意率：</span>
              <span style="font-size: 13px; color: #060606;">{{item.satisfieRate}}</span>
            </div>
          </div>
        </div>
      </div>
      <div class="btn-box">
        <u-button class="btn" type="primary" ripple shape="circle" @click="toPage('pages/satisfaction')">我要评价</u-button>
      </div>
    </template>
    <Empty v-if="!loading && !list.length"></Empty>
  </div>
</template>
<script>
import Empty from "../../../components/Empty.vue";
import { getAppraiseListApi } from "../../../api/satisfaction";

export default {
  components: { Empty },
  data() {
    return {
      loading: false,
      list: [],
    };
  },
  onShareAppMessage() {},
  onShow() {
    this.loading = true;
    wx.showLoading({
        title: "加载中...",
    });
    getAppraiseListApi(2).then((res) => {
      this.list = [...res.data];
      wx.hideLoading();
      this.loading = false;
    });
  },
  methods: {
    toPage(url, params) {
      this.$u.route({
        url,
        params,
      });
    },
  },
};
</script>

<style scoped lang="scss">
@import "../../../assets/scss/common.scss";

.container {
  min-height: 100vh;
  background-color: #fff;
  box-sizing: border-box;
  padding: 15px;
  .title-box {
    width: 100%;
    height: 50px;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2;
    background-color: #fff;
    box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.1) !important;
    .title {
      margin-top: 15px;
      margin-left: 20px;
      font-weight: 600;
    }
  }
  .data-box {
    margin: 50px 0 70px 0;
    width: 100%;
    .data-title {
      display: flex; 
      align-items: center; 
      font-size: 14px;
      .title-number {
        height: 18px;
        width: 18px;
        color: #fff;
        margin-right: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
      }
    }
    .data-content {
      display: flex;
      justify-content: space-between;
      height: 40px;
      align-items: center;
      width: 100%;
      margin-left: 10px;
    }
  }
  .btn-box {
    position: fixed;
    left: 0;
    bottom: 0;
    z-index: 10;
    width: 100%;
    height: 80px;
    background-color: #fff;
    .btn {
      position: fixed;
      left: 30px;
      right: 30px;
      bottom: 25px;
    }
  }
}
</style>